package com.n9.qq.android.login.tlv;

import com.n9.qq.util.Util;

import java.util.Objects;

/**
 * @author ice
 * @since 2019/2/19 13:40
 */
public class Tlv0002 extends BaseTlv {
    int i = 0;
    public Tlv0002() {
        this.cmd = 0x0002;
    }

    /**
     * @param vfCodeBytes   验证码字节码
     * @param recvBytes     登陆包接收到的数据
     * @return
     */
    public byte[] getData(byte[] vfCodeBytes, byte[] recvBytes) {
        if (Objects.isNull(vfCodeBytes)) {
            vfCodeBytes = new byte[0];
        }
        if (Objects.isNull(recvBytes)) {
            recvBytes = new byte[0];
        }

        int len = vfCodeBytes.length + 6 + recvBytes.length;
        byte[] data = new byte[len];
        int index = 0;
        Util.int16_to_buf(data, index, i);
        index += 2;
        Util.int16_to_buf(data, index, vfCodeBytes.length);
        index +=2;
        System.arraycopy(vfCodeBytes, 0, data, index, vfCodeBytes.length);
        index += vfCodeBytes.length;

        Util.int16_to_buf(data, index, recvBytes.length);
        index +=2;
        System.arraycopy(recvBytes, 0, data, index, recvBytes.length);

        return this.getBufData(data);
    }

}
